package com.lvchen.ui.fourfunction;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lvchen.R;
import com.lvchen.common.MyApplication;
import com.lvchen.common.base.BaseFragment;
import com.lvchen.ui.fourfunction.photograph.TakePhotoActivity;
import com.nightonke.boommenu.BoomButtons.ButtonPlaceEnum;
import com.nightonke.boommenu.BoomButtons.OnBMClickListener;
import com.nightonke.boommenu.BoomButtons.SimpleCircleButton;
import com.nightonke.boommenu.BoomMenuButton;
import com.nightonke.boommenu.ButtonEnum;
import com.nightonke.boommenu.Piece.PiecePlaceEnum;
import com.siberiadante.titlelayoutlib.TitleBarLayout;


/**
 * 功能四
 */
public class FourFragment extends BaseFragment {

    private TitleBarLayout tb_title;

    private BoomMenuButton bmb;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        mContentView = inflater.inflate(R.layout.fragment_four, container, false);
        ensureUi();

        return mContentView;
    }

    private void ensureUi() {

        tb_title = (TitleBarLayout) mContentView.findViewById(R.id.tb_title);
        tb_title.setIsHaveLine(false);
        tb_title.setLeftBackViewVisible(View.GONE);

        bmb = (BoomMenuButton) mContentView.findViewById(R.id.bmb);
        bmb.setButtonEnum(ButtonEnum.SimpleCircle);
//        bmb.setPiecePlaceEnum(PiecePlaceEnum.DOT_3_1);
        bmb.setPiecePlaceEnum(PiecePlaceEnum.Share);
        bmb.setButtonPlaceEnum(ButtonPlaceEnum.SC_3_1);
        bmb.setNormalColor(ContextCompat.getColor(mContext,R.color.blue));
        bmb.setInFragment(true);

        bmb.setShareLineLength(45);
        bmb.setShareLineWidth(5);
        bmb.setDotRadius(12);
        bmb.setShareLine1Color(Color.WHITE);
        bmb.setShareLine2Color(Color.WHITE);

        for (int i = 0; i < bmb.getButtonPlaceEnum().buttonNumber(); i++) {
            bmb.addBuilder(new SimpleCircleButton.Builder().normalImageRes(R.mipmap.ic_launcher).normalColorRes(R.color.white).listener(new OnBMClickListener() {
                @Override
                public void onBoomButtonClick(int index) {
                    switch (index){
                        case 0://
                            TakePhotoActivity.goToThisActivity(mActivity);
                            break;
                        case 1://
                            ExampleActivity.goToThisActivity(mActivity);
                            break;
                        default:
                            GravityActivity.goToThisActivity(mActivity);
                            break;
                    }
                }
            }));
        }

    }


    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

    }

    @Override
    protected View getContentView() {
        return mContentView;
    }

    private void getData() {

    }

}